//
//  ForgetPasswordVC.m
//  WanCaiC8
//
//  Created by tangang on 2018/3/29.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "ForgetPasswordVC.h"
#import "VerificationCodeVC.h"
#import "LoginVM.h"
@interface ForgetPasswordVC ()
@property (weak, nonatomic) IBOutlet UITextField *textPhone;
@property (weak, nonatomic) IBOutlet UIButton *btnNext;

@end

@implementation ForgetPasswordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"忘记密码";
    self.view.backgroundColor=[UIColor whiteColor];
    _btnNext.layer.cornerRadius=25;
    _btnNext.layer.masksToBounds=YES;
    // Do any additional setup after loading the view.
}


- (IBAction)next:(UIButton *)sender {
    if (_textPhone.text.length!=11) {
        [SVProgressHUD showErrorWithStatus:@"请输入正确的手机号"];
        return;
    }
    [[LoginVM manage] validateWithMobile:_textPhone.text andSuccess:^(id returnValue) {
        [SVProgressHUD showErrorWithStatus:@"手机号码已存在"];
    } andFail:^(NSString *errorMessage, NSError *error) {
        if ([errorMessage intValue]==50000) {
            VerificationCodeVC *vc=[[UIStoryboard storyboardWithName:@"CLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"VerificationCodeVC"];
            vc.type=VerificationCodeTypeForgetPassword;
            vc.userInfo=[[NSMutableDictionary alloc]initWithObjectsAndKeys:_textPhone.text,@"Phone", nil];
            [self.navigationController pushViewController:vc animated:YES];
        }
    }];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
